package aa;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;

public class Main {

	public void main(String[] args) throws Exception {
//		String path="C:/Users/PC/Desktop/qq.jpg";
// 		File file = new File(path);	
// 		InputStream is = new FileInputStream(file);
// 		String a=inputStream2String(is);
// 		
// 		ByteArrayInputStream stream = new ByteArrayInputStream(a.getBytes());
// 		File destFile = new File("C:/Users/PC/Desktop/","a.jpg");
		String path="C:/Users/PC/Desktop/qq.jpg";
 		File file = new File(path);
 		
 		InputStream is = new FileInputStream(file);
 		File destFile = new File("C:/Users/PC/Desktop","a.jpg");
 		OutputStream os = new FileOutputStream(destFile);
 		byte[] buffer = new byte[1024];
 		int length = 0 ;
 		while((length = is.read(buffer))>0){
 			os.write(buffer, 0, length);
 		}
 		is.close();
 		os.close();
		
		
	}
	public String inputStream2String(InputStream is) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(is));
		StringBuffer buffer=new StringBuffer();
		String line="";
		while((line=in.readLine())!=null){
			buffer.append(line);
		}
	return buffer.toString(); 
	}
}
